<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>用户登录</title>
		<link href="css/mui.min.css" rel="stylesheet"/>
		<script src="js/mui.min.js"></script>
		<script src="js/addressinitialization.js"></script>
		<script src="http://pv.sohu.com/cityjson?ie=utf-8"></script>
		<link rel="stylesheet" href="css/mui.min.css">
		<link rel="stylesheet" type="text/css" href="css/index.css"/>
		<script type="text/javascript" charset="utf-8">
    	mui.init();
      	window.onload=function(){
			butclick();
			moveinput();//移动输入框
		}
//		作者：984326869@qq.com
//     	时间：2019-08-10
//     	描述：登陆界面
		function butclick(){
			document.getElementById("loginBtn").addEventListener('click',function(){
				var username=mui("#username")[0].value;
				var password=mui("#password")[0].value;
				var Android_URL=IP+'/ias/androidUser/login';
				console.log(Android_URL);
				if(username=="")
				{
					mui.toast("用户名不能为空！");
				}
				else if(password=="")
				{
					mui.toast("密码不能为空！");
				}
				else{
					mui.ajax(Android_URL,{
					data:{
					username : username,
					password : password,
					ip : returnCitySN["cip"]
					},
					type: 'post',
					dataType: 'json',
					timeout: 10000,
					headers:{'Content-Type':'application/json'},
					//登陆等待
					beforeSend: function(data) {
      				plus.nativeUI.showWaiting("登陆中...");
   				 	},
					success: function(data){
						if(data.result == 'error'){
							mui.toast(data.msg);
							plus.nativeUI.closeWaiting();
						}else{
							//账号密码正确跳转至主菜单界面
							localStorage.clear();
							plus.nativeUI.closeWaiting();
							mui.toast("登陆成功");
							if(password=="123")
							{
								//强制修改密码
								window.location="forcedissonionPassword.html";
							}else{
								//正常登陆
								window.location="main.html";
							}
						}
					},
					error: function(xhr, type, errorThrown){
						//错误处理
						plus.nativeUI.closeWaiting();
						mui.toast("登陆失败，请检查网络");
					}
					});	
				}
			});
		}
		//点击输入框时隐藏logo并将输入框上移
		function moveinput(){
			var username = document.getElementById("username");
			var password=document.getElementById('password');
			username.addEventListener('focusin',function(){
				document.getElementById("img").hidden="hidden";
			})
			username.addEventListener('focusout',function(){
				document.getElementById("img").hidden="";
			})
			password.addEventListener('focusin',function(){
				document.getElementById("img").hidden="hidden";
			})
			password.addEventListener('focusout',function(){
				document.getElementById("img").hidden="";
			})
		}
		
		//首页返回键处理
    	//处理逻辑：1秒内，连续两次按返回键，则退出登录；
    	var first = null;
    	mui.back = function() {
       	 //首次按键，提示‘再按一次退出应用’
       	 if (!first) {
         	   first = new Date().getTime();
          	  mui.toast('再按一次退出应用');
          	  setTimeout(function() {
         	       first = null;
          	  }, 1000);
        	} else {
         	   if (new Date().getTime() - first < 1000) {
        	        plus.runtime.quit();
        	    }
       	 }
    	};
    </script>
    
</head>
<body>
	<div class="wrap">
		<!--登陆部分-->
		<div class="container">	
			<!--log部分-->
			<div class="logo" style="text-align: center;" id="img"><img src="img/logo.png" class="index_img"></div>
			<!--登陆内容部分-->
			<div class="my-container">
					<div class="login-row">
					<label><span class="mui-icon mui-icon-contact"></span></label>
					<input type="text" id="username" class="mui-input-clear mui-input" name="username"  placeholder="用户名">
				</div>
				
				<div class="login-row">
					<label><span class="mui-icon mui-icon-locked"></span></label>
					<input type="password" id="password" name="password" class="mui-input-password" placeholder="请输入密码">
				</div>	
		    <input type="button" id='loginBtn' class="mui-input-range" value="登 陆" style="color: white;background-color: #007AFF;width: 80px;height: 80px;"></input>
		<!--登陆表单结束-->
			<!--<div class="link-area">
				<a id='reg'>注册账号</a> <span class="spliter">|</span> <a id='forgetPassword'>忘记密码</a>
				</div>
				
			
		</div>-->
	</div>
</body>
</html>